home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DBio.more / USeqPrint-seq.cpp < prev    next >
Text File  |  1996-07-05  |  20KB  |  747 lines

  1. // USeqPrint.seq.p 
  2. // d.g.gilbert, 1991 
  3.  
  4. /*
  5.     one sequence print
  6.     
  7. */
  8.  
  9. #pragma segment SeqPrint
  10.  
  11. CONST
  12.     kMacdrawHeaderSize == 512;
  13.  
  14.     kShadeInvert == 1;
  15.     kShadeGray50 == 2;
  16.     kShadeGray25 == 3;
  17.     kShadeGray75 == 4;
  18.     kShadeStipple50    == 5;
  19.     kShadeStipple25    == 6;
  20.     kShadeStipple75    == 7;
  21.     
  22.     mColorButHit == 1001;
  23.     mMonoButHit    == 1002;
  24.  
  25.   kMaxNameWidth == 120;
  26.     kNucSpace     == 0; //was 2
  27.     kBasesPerLine == 50; //was 40
  28.     kNucBorder    == 6;
  29.     kSeqLinesPerParagraph == 5;
  30.     
  31.     kSeqPrintWindowRSRCID == 1032;
  32.  
  33.  
  34.  
  35. // TSeqPrintDocument -----------------------------------------------
  36.  
  37.  
  38. pascal void TSeqPrintDocument::ISeqPrintDocument(OSType fileType, TDocument parentDoc, 
  39.                                                     TSequence        aSeq; longint startbase, nbases)
  40.  
  41. VAR  aFile: TFile;
  42. {
  43.     fSeqPrintView = NULL;
  44.     fSeq= NULL;
  45.     fParentDoc= parentDoc;
  46.     FailNIL( aSeq);
  47.     fSeq= TSequence(aSeq->Clone());
  48.     if (nbases<1) fSeq->GetSelection( startbase,nbases);
  49.     fFirstBase= startBase;
  50.     fNBases= nbases;
  51.     
  52.     /*---
  53.     New(aFile); aFile->IFile(...);
  54.     aname= parentDoc.name + '.dotplot';
  55.     vol= parentdoc.vol;
  56.     dirid= parentdoc.dirid;
  57.     err= aFile->SpecifyWithTrio( name/vol/dirid);
  58.     ----*/
  59.     aFile= NewFile(fileType, kSAppSig, kUsesDataFork, kUsesRsrcFork, !kDataOpen, !kRsrcOpen);
  60.     IFileBasedDocument(aFile, fileType);
  61.     fSavePrintInfo = FALSE; //was TRUE;
  62. }
  63.  
  64. pascal void TSeqPrintDocument::FreeData(void)
  65. {
  66.     if (fSeq!=NULL)    fSeq->Free();
  67.     fSeq= NULL;
  68. }
  69.  
  70.  
  71. pascal void TSeqPrintDocument::Free(void) // override 
  72. {
  73.     FreeData();
  74.     inherited::Free();
  75. }
  76.  
  77.  
  78. pascal void TSeqPrintDocument::Close(void) /* override */ 
  79. {
  80.         /* patches for prefwindow */        
  81.     if ((fSeqPrintView->fUseColor) && (fColorButton!=NULL)) fColorButton->fHilite= TRUE;
  82.     this->SetChangeCount(0); //so we don't always get Save? yes/no/canc dlog 
  83.   inherited::Close();
  84. }
  85.  
  86.  
  87.  
  88. pascal void TSeqPrintDocument::DoMakeViews(Boolean forPrinting) // override 
  89. VAR
  90.         aWindow    : TWindow;
  91.         minSize    : Point;
  92.         maxSize    : Point;
  93.         vSize     : Vpoint;
  94.         aTEDlog    : TDialogViewTE;
  95. {
  96.     aWindow = gViewServer->NewTemplateWindow(kSeqPrintWindowRSRCID, this);
  97.     FailNil(aWindow);
  98.     
  99.     fSeqPrintWind = TSeqPrintWind(aWindow);
  100.     fSeqPrintWind->ISeqPrintWind();
  101.     fSeqPrintWind->fRedrawBut= TButton(aWindow->FindSubView('bRDR'));
  102.     
  103.     fSeqPrintView = TSeqPrintView(aWindow->FindSubView('PrVw'));
  104.     FailNil(fSeqPrintView);
  105.     fSeqPrintView->InstallControls();
  106.  
  107.     fColorButton= TIcon(aWindow->FindSubView('iClr'));
  108.     fColorButton->fEventNumber= mColorButHit;
  109.     fMonoButton = TIcon(aWindow->FindSubView('iB&W'));
  110.     fMonoButton->fEventNumber= mMonoButHit;
  111.     fSeqPrintView->fUseColor= fColorButton->fHilite;  
  112.     fColorButton->fHilite= FALSE;
  113.     fMonoButton->fHilite= FALSE;
  114.     if (!gConfiguration.hasColorQD) {
  115.         fColorButton->ViewEnable(FALSE, kDontRedraw);
  116.         fColorButton->Show(FALSE, kDontRedraw);
  117.         fMonoButton->ViewEnable(FALSE, kDontRedraw);
  118.         fMonoButton->Show(FALSE, kDontRedraw);
  119.         fSeqPrintView->fUseColor    = FALSE;
  120.         }
  121.     
  122.         // get our damn data into view 
  123.     fSeqPrintView->SetDrawOptions();
  124.     
  125.         //?? need something to get text in style TE's displayed !
  126.  
  127.     // set window's resize limits so it can't become wider than the SeqPrintview's edge 
  128.     WITH aWindow->fResizeLimits){
  129.         minSize = topLeft;
  130.         maxSize = botRight;
  131.         }
  132.     WITH maxSize)h = Min( 2 + fSeqPrintView->fSize.h + kSBarSizeMinus1, h);
  133.     //-- aWindow->SetResizeLimits(minSize, maxSize); << bad !!
  134.     
  135.     //? may need to show TEView in PrintView... ?
  136.     this->ShowReverted();   
  137.  
  138. }
  139.  
  140.  
  141. pascal void TSeqPrintDocument::UntitledName(Str255 VAR noName) // override 
  142. //called AFTER .Idoc and .MakeViews 
  143. {
  144.     noName= Concat(fSeq->fName,' PrettyPrint'); 
  145.     if ((fWindowList != NULL) && (fWindowList.GetSize > 0))         
  146.         TWindow(fWindowList->First())->SetTitle(noName);
  147. }
  148.  
  149.  
  150. pascal TFile TSeqPrintDocument::DoMakeFile(itsCommandNumber:CommandNumber); // override 
  151. {
  152.     DoMakeFile= NewFile(fScrapType, gApplication->fCreator, kUsesDataFork, kUsesRsrcFork, 
  153.                                                 !kDataOpen, !kRsrcOpen);
  154. }
  155.  
  156.  
  157.  
  158. pascal void TSeqPrintDocument::DoNeedDiskSpace(TFile itsFile,
  159.                                                             long VAR dataForkBytes, rsrcForkBytes)
  160. {
  161.     //)!get Print record requirements 
  162.     //- inherited::DoNeedDiskSpace(dataForkBytes, rsrcForkBytes); 
  163.     
  164.     dataForkBytes = dataForkBytes + kMacdrawHeaderSize  /*+ sizeof window pict */;
  165.     
  166.     /*-- if you really want to know pict size:
  167.     fSeqPrintView->WriteToDeskScrap(); 
  168.     len= fSeqPrintView->GivePasteData( NULL, 'PICT');
  169.     rsrcForkBytes = rsrcForkBytes + kRsrcTypeOverhead + kRsrcOverhead + sizeof(DocState);
  170.     ---*/
  171. }
  172.  
  173. pascal void TSeqPrintDocument::DoRead(aFile:TFile; Boolean forPrinting)
  174. {
  175.     //-- inherited::DoRead(aRefNum, rsrcExists, forPrinting);)!read print info stuff
  176.     // This is a Write-Only document == PICT of output drawing, no reading... ?
  177. }
  178.  
  179.  
  180. pascal void TSeqPrintDocument::DoWrite(TFile aFile, Boolean makingCopy)
  181. VAR
  182.         longint        len, count;
  183.         hPict            : handle;
  184.         header        : packed array [1..kMacdrawHeaderSize] of char;
  185.         fi                : FailInfo;
  186.  
  187.     pascal void HdlDoWrite(OSErr error, long message)
  188.     {
  189.         if (hPict != NULL) DisposHandle( hPict);
  190.     }
  191.  
  192. {
  193.     //- inherited::DoWrite(aRefNum, makingCopy);     --)NO write print info stuff
  194.  
  195.     fSeqPrintView->WriteToDeskScrap();
  196.     
  197.     hPict= NewHandle(0);
  198.     CatchFailures(fi, HdlDoWrite);
  199.     len= fSeqPrintView->GivePasteData( hPict, 'PICT');
  200.     if ((len > 0)) {
  201.         fillchar(header, kMacdrawHeaderSize, ((char)(0)));  
  202.         count = kMacdrawHeaderSize;
  203.         FailOSErr( aFile->WriteData( &header, count));
  204.         count= len;
  205.         HLock(hPict);
  206.         FailOSErr( aFile->WriteData( ptr((*hPict)), count));
  207.         HUnlock(hPict);    
  208.         }
  209.     Success(fi);
  210.     DisposHandle( hPict);
  211. }
  212.  
  213.  
  214.  
  215.  
  216. // TSeqPrintWind ------------------------- 
  217.  
  218. pascal void TSeqPrintWind::ISeqPrintWind(void)
  219. {
  220.     IPrefWindow();
  221.     fWantSave= TRUE;
  222. }
  223.  
  224. pascal void TSeqPrintWind::SetPrefID(void) /* override */ 
  225. {
  226.     gPrefWindID= kSeqPrintWindowRSRCID; gPrefWindName= 'TSeqPrintWind';
  227. }
  228.  
  229. pascal void TSeqPrintWind::DoEvent(EventNumber eventNumber, 
  230.                                             TEventHandler        source; TEvent event) // override 
  231. VAR
  232.         TSeqPrintView        aSeqPrintView;
  233.  
  234. {
  235.     aSeqPrintView= TSeqPrintDocument(fDocument).fSeqPrintView;
  236.     //- aSeqPrintView->SetDrawOptions();
  237.  
  238.     switch (eventNumber) {
  239.         mColorButHit: {
  240.                 aSeqPrintView->fUseColor= TRUE;
  241.                 aSeqPrintView->ForceRedraw();
  242.                 }
  243.         mMonoButHit: {
  244.                 aSeqPrintView->fUseColor= FALSE;
  245.                 aSeqPrintView->ForceRedraw();
  246.                 }
  247.         mButtonHit: if ((source == fRedrawBut)) {
  248.                 aSeqPrintView->SetDrawOptions();
  249.                 aSeqPrintView->ForceRedraw();
  250.                 }            else 
  251.                 inherited::DoEvent(eventNumber,source, event); 
  252.  
  253.         otherwise
  254.             inherited::DoEvent(eventNumber,source, event); 
  255.         }
  256. }
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263. // TSeqPrintView -------------------------------------
  264.  
  265. pascal void TSeqPrintView::Free(void) // override 
  266. {
  267.     inherited::Free();
  268. }
  269.  
  270.  
  271. pascal void TSeqPrintView::Initialize(void) // override 
  272. //called by IObject/via IView...
  273. CONST
  274.     //- kBasesPerLine == 50;
  275.     kTenSpacer     == 10;
  276. {
  277.     inherited::Initialize();
  278.     
  279.     fSeqPrintDocument= NULL;
  280.     fFirstBase= 0;  
  281.     fNbases= 0;  
  282.     fSeq= NULL;  
  283.  
  284.     fStyleName= NULL;
  285.     fStyleBase= NULL;
  286.     fStyleNums= NULL;
  287.     fUseColor= TRUE;
  288.     fDoTopIndex= TRUE;
  289.     fDoLeftIndex= FALSE;
  290.     fDoRightIndex= FALSE;
  291.     fDoLeftName= TRUE;
  292.     fDoRightName= FALSE;
  293.     fBasesPerLine= kBasesPerLine;
  294.     fTenSpacer= kTenSpacer;
  295.     fNameWidth= kMaxNameWidth;
  296.     fIndexWidth= kMaxNameWidth;
  297. }
  298.  
  299.  
  300. pascal void TSeqPrintView::ISeqPrintView( TSeqPrintDocument itsDocument, Boolean forClipboard)
  301. VAR
  302.         itsSize        : VPoint;
  303.         aHandler    : TStdPrintHandler;
  304.         sd                : SizeDeterminer;
  305. {
  306.     fSeqPrintDocument = TSeqPrintDocument(itsDocument);
  307.     fFirstBase= fSeqPrintDocument->fFirstBase;  
  308.     fNbases= fSeqPrintDocument->fNbases;  
  309.     fSeq= fSeqPrintDocument->fSeq;  
  310.     
  311.     SetVPt(itsSize, kMaxCoord, kMaxCoord);
  312.     if (forClipboard)
  313.         sd = sizeVariable
  314.     else
  315.         sd = sizeFillPages;
  316.     //- IView(itsDocument, NULL, gZeroVPt, itsSize, sd, sd); 
  317.     IGridView( itsDocument, NULL, gZeroVPt, itsSize, sd, sd, 10, 50, 20, 20, 
  318.                                                     FALSE, FALSE, 0, 0, FALSE);
  319.  
  320. #if FALSE                                        //!!! Need to handle this
  321.     if (forClipboard) fWouldMakePICTScrap = TRUE;
  322. #endif
  323.     if (!forClipboard) {
  324.         New(aHandler);
  325.         FailNil(aHandler);
  326.         aHandler->IStdPrintHandler(itsDocument, this, !kSquareDots, kFixedSize, kFixedSize);         
  327.         }
  328. }
  329.  
  330.  
  331.  
  332. pascal void TSeqPrintView::DoPostCreate(TDocument itsDocument) // override 
  333. VAR  aHandler: TStdPrintHandler;
  334. {
  335.     inherited::DoPostCreate(itsDocument);
  336.     fSeqPrintDocument= TSeqPrintDocument(itsDocument);
  337.     fFirstBase= fSeqPrintDocument->fFirstBase;  
  338.     fNbases= fSeqPrintDocument->fNbases;  
  339.     fSeq= fSeqPrintDocument->fSeq;  
  340.     New(aHandler);
  341.     FailNil(aHandler);
  342.     aHandler->IStdPrintHandler(itsDocument, this, !kSquareDots, kFixedSize, kFixedSize);     
  343. }
  344.  
  345.  
  346. pascal void TSeqPrintView::InstallControls(void)
  347. VAR  aWindow    : TWindow;
  348.          sh    : StringHandle;
  349. {
  350.     aWindow= GetWindow;
  351.     
  352.     fTopIndex    = TCheckBox(aWindow->FindSubView('cTop'));
  353.     fLeftIndex= TCheckBox(aWindow->FindSubView('cLft'));
  354.     fRightIndex= TCheckBox(aWindow->FindSubView('cRgt'));
  355.     fLeftName    = TCheckBox(aWindow->FindSubView('nLft'));
  356.     fRightName= TCheckBox(aWindow->FindSubView('nRgt'));
  357.     
  358.     fStyleName= TDlogTextView(aWindow->FindSubView('tNam'));
  359.     fStyleBase= TDlogTextView(aWindow->FindSubView('tBas'));
  360.     fStyleNums= TDlogTextView(aWindow->FindSubView('tNum'));
  361.  
  362.     if (fStyleName!=NULL) fStyleName->SetText('Names');
  363.     if (fStyleBase!=NULL) fStyleBase->SetText('Bases');
  364.     if (fStyleNums!=NULL) fStyleNums->SetText('Index');
  365.     /*- this->ShowReverted();  -- need this in MakeViews to get displayed !?!?! --*/ 
  366. }
  367.  
  368.  
  369. pascal void TSeqPrintView::FindNameWidth(void)
  370. VAR    
  371.         linesPerParag, numLinesPerSeq,
  372.         integer        maxNameWid,fontheight, maxdeep;
  373.         GrafPtr        savePort;
  374.         nums    : Str255;
  375.         longint        lastBase;
  376.         fi        : fontInfo;
  377.         
  378.     pascal void GetNameWidth(TSequence aSeq)
  379.     VAR  aName        : Str63;
  380.     {
  381.         if (aSeq!=NULL) {
  382.             aName= aSeq->fName;
  383.             maxNameWid= max(maxNameWid, StringWidth(aName));
  384.             } 
  385.     }
  386. {
  387.     if (fStyleName == NULL) fNameStyle= gPrintNameStyle 
  388.     else fNameStyle= fStyleName->fTextStyle;
  389.     if (fStyleBase == NULL) fBaseStyle= gPrintNucStyle 
  390.     else fBaseStyle= fStyleBase->fTextStyle;
  391.     if (fStyleNums == NULL) fNumStyle= gPrintNameStyle 
  392.     else fNumStyle= fStyleNums->fTextStyle;
  393.     maxdeep= 0;
  394.     
  395.     GetPort( savePort);
  396.     SetPort( gWorkPort);
  397.     //$PUSH*/ /*$H-*/ SetPortTextStyle(fNameStyle);  /*$POP
  398.     maxNameWid= 0;
  399.     //- fAlnList->Each(GetNameWidth);
  400.     GetNameWidth( fSeq);
  401.     fNameWidth= Min( maxNameWid + kNucBorder, kMaxNameWidth); 
  402.     GetFontInfo(fi);
  403.     fontheight= fi.ascent+fi.descent+fi.leading;
  404.     maxdeep= Max(maxdeep, fontheight);
  405.     
  406.     //$PUSH*/ /*$H-*/ SetPortTextStyle(fNumStyle);  /*$POP
  407.     lastBase= fFirstBase + fNBases;
  408.     NumToString( lastBase, nums);
  409.     fIndexWidth= StringWidth(nums) + kNucBorder;
  410.     GetFontInfo(fi);
  411.     fontheight= fi.ascent+fi.descent+fi.leading;
  412.     maxdeep= Max(maxdeep, fontheight);
  413.     
  414.     //$PUSH*/ /*$H-*/ SetPortTextStyle(fBaseStyle);  /*$POP
  415.     fBaseWidth= CharWidth('G') + kNucSpace;
  416.     GetFontInfo(fi);
  417.     fontheight= fi.ascent+fi.descent+fi.leading;
  418.     maxdeep= Max(maxdeep, fontheight);
  419.     
  420.         //fix grid size: 
  421.     DelColLast( fNumOfCols);
  422.     InsColLast( fBasesPerLine+4, fBaseWidth);
  423.     
  424.     numLinesPerSeq= (fBasesPerLine - 1 + fNBases) / fBasesPerLine;
  425.     //- linesPerParag= fNumSeqs + 2; */ /*+ top index + bottom spacer
  426.     linesPerParag= kSeqlinesPerParagraph;
  427.     
  428.     DelRowLast( fNumOfRows);
  429.     //- InsRowLast( linesPerParag * numLinesPerSeq, maxDeep);
  430.     InsRowLast( numLinesPerSeq 
  431.         + 2*((numLinesPerSeq+linesPerParag) / linesPerParag), maxDeep); 
  432.     
  433.     SetPort( savePort);
  434. }
  435.  
  436.  
  437. pascal void TSeqPrintView::SetDrawOptions(void) 
  438. VAR        
  439.         integer        wid, i ;
  440.         Str255        aStr;
  441. {
  442.     FindNameWidth();
  443.  
  444.     if (fTopIndex == NULL) fDoTopIndex= TRUE else fDoTopIndex= fTopIndex->IsOn();  
  445.     if (fLeftIndex == NULL) fDoLeftIndex= FALSE else fDoLeftIndex= fLeftIndex->IsOn();  
  446.     if (fRightIndex == NULL) fDoRightIndex= FALSE else fDoRightIndex= fRightIndex->IsOn();  
  447.     if (fLeftName == NULL) fDoLeftName= FALSE else fDoLeftName= fLeftName->IsOn();  
  448.     if (fRightName == NULL) fDoRightName= FALSE else fDoRightName= fRightName->IsOn();  
  449.     
  450.     if (fDoLeftName) wid= fNameWidth else wid= 0;
  451.     this->SetColWidth( 1, 1, wid);
  452.     if (fDoLeftIndex) wid= fIndexWidth else wid= 0;
  453.     this->SetColWidth( 2, 1, wid);
  454.     
  455.     FOR i= 1 TO fBasesPerLine){
  456.         if ((i<fBasesPerLine) && (i % 10 == 0)) SetColWidth( i+2, 1, fBaseWidth+fTenSpacer)
  457.         else SetColWidth( i+2, 1, fBaseWidth);
  458.         }
  459.         
  460.     if (fDoRightIndex) wid= fIndexWidth else wid= 0;
  461.     this->SetColWidth( 2+fBasesPerLine+1, 1, wid);
  462.     if (fDoRightName) wid= fNameWidth else wid= 0;
  463.     this->SetColWidth( 2+fBasesPerLine+2, 1, wid);
  464. }
  465.  
  466.  
  467. pascal void TSeqPrintView::DrawRangeOfCells(GridCell startCell, stopCell, VRect aRect) 
  468.                     // override 
  469. {
  470.     laserLine( 2, 4); // set laserline smaller ...
  471.     
  472.     inherited::DrawRangeOfCells( startCell, stopCell, aRect);
  473. }
  474.  
  475.  
  476.  
  477. pascal void TSeqPrintView::DrawCell(GridCell aCell, VRect aRect) // override 
  478. CONST
  479.     kFontDescent == 2;
  480.     kIndexRise == 1;
  481. VAR
  482.     longint        atBase ;
  483.     integer        linesPerParag ;
  484.     longint        atSeq, seqLine ;    
  485.     Boolean        doTopIndex, doSequence;
  486.     
  487.     
  488.     pascal void drawTopIndex( longint atBase)  
  489.     VAR  nums    : str255;
  490.              integer        chRight, chLeft, rowtop, ws;
  491.     {
  492.     //$PUSH*/ /*$H-*/ SetPortTextStyle(fNumStyle);  /*$POP
  493.         chleft    = aRect.left;
  494.         chRight    = chleft + fBaseWidth; //fix for extra spacers
  495.         rowtop    = aRect.bottom-kIndexRise;  
  496.         MoveTo( chleft+kNucSpace, rowtop);
  497.         if (atBase % 10 == 4) then begin
  498.             Line(0,-1);
  499.             NumToString( atBase+1, nums);
  500.             ws= StringWidth(nums);
  501.             Move(-ws / 2, -1);
  502.             DrawString(nums);
  503.             }        else
  504.             Line(0,-2);
  505.         MoveTo( chleft, rowtop);
  506.         LineTo( chright, rowtop);
  507.     }
  508.  
  509.     pascal void drawSideIndex(longint atBase, leftBorder)
  510.     str255        VAR  nums ;
  511.     {
  512.     //$PUSH*/ /*$H-*/ SetPortTextStyle(fNumStyle);  /*$POP
  513.         MoveTo( aRect.right-leftBorder, aRect.bottom-kFontDescent);
  514.         NumToString( atBase+1, nums);
  515.         Move( -StringWidth(nums), 0);
  516.         DrawString(nums);
  517.     }
  518.  
  519.     pascal void DrawName(integer atSeq, rightBorder, longint atBase)
  520.     VAR     aName    : Str63;
  521.                 aSeq    : TSequence;
  522.     {
  523.         //- aSeq= fAlnList->SeqAt( atSeq); 
  524.         aSeq= fSeq;
  525.         if (aSeq!=NULL) {
  526.     //$PUSH*/ /*$H-*/ SetPortTextStyle(fNameStyle);  /*$POP
  527.             MoveTo( aRect.left+rightBorder, aRect.bottom-kFontDescent);
  528.             aName= aSeq->fName;
  529.             DrawString(aName);
  530.             } 
  531.     }
  532.  
  533.     pascal void DrawNuc(integer atSeq, longint atBase)
  534.     VAR
  535.          integer        rowbot, nucwidth, cw, rowleft;
  536.         hSeq        : CharsHandle;
  537.         ch            : char;
  538.         aSeq        : TSequence;
  539.         myRect    : VRect;
  540.     {
  541.         //- aSeq= fAlnList->SeqAt( atSeq); 
  542.         aSeq= fSeq;
  543.         if (aSeq!=NULL) {
  544.         //$PUSH*/ /*$H-*/ SetPortTextStyle(fBaseStyle);  /*$POP
  545.             nucwidth= fBaseWidth; //aRect.right - aRect.left; 
  546.             rowleft= aRect.left;
  547.             rowbot = aRect.bottom - kFontDescent;  
  548.             myRect= aRect;
  549.             myRect.right= myRect.left + fBaseWidth; //fix for extra spacers
  550.             handle(hSeq)= aSeq->fBases;
  551.             ch= (*hSeq)^[atBase];
  552.             if (ch == indelSoft) then ch= indelHard; //look better for output...
  553.  
  554.             if (fUseColor) CASE ch OF
  555.                 'A','a': RGBForeColor( gAcolor);
  556.                 'C','c': RGBForeColor( gCcolor);
  557.                 'G','g': RGBForeColor( gGcolor);
  558.                 'T','t',
  559.                 'U','u': RGBForeColor( gTcolor);
  560.                 otherwise
  561.                                  RGBForeColor( gNcolor);
  562.                 }            else
  563.                 RGBForeColor( gNcolor);
  564.                                                 
  565.             cw= (nucwidth - charwidth(ch)) / 2;
  566.             MoveTo( rowleft+cw, rowbot);
  567.             DrawChar(ch);
  568.             TextMode(srcOr); //? srcOr/srcCopy
  569.             }
  570.     }  
  571.  
  572. {
  573.     linesPerParag= kSeqLinesPerParagraph + 2; // 5 seq + top index + top spacer
  574.     atSeq     = ((aCell.v-1) % linesPerParag) - 1;
  575.     
  576.     if ((atSeq < 0) || (atSeq > kSeqLinesPerParagraph)) {
  577.         //spacer line
  578.         doTopIndex= FALSE;
  579.         doSequence= FALSE;
  580.         seqLine= ((aCell.v-1) / linesPerParag) * kSeqLinesPerParagraph + atSeq+1; //???
  581.         }    else if ((atSeq == 0)) {
  582.         doTopIndex= TRUE;
  583.         doSequence= FALSE;
  584.         seqLine= ((aCell.v-1) / linesPerParag) * kSeqLinesPerParagraph + atSeq; //???
  585.         }    else {
  586.         //sequence line
  587.         doTopIndex= FALSE;
  588.         doSequence= TRUE;
  589.         seqLine= ((aCell.v-1) / linesPerParag) * kSeqLinesPerParagraph + atSeq-1; //???
  590.         }
  591.  
  592.     if ((aCell.h == 1)) {
  593.         //nameleft
  594.         atBase= fFirstBase + min( fNbases, seqLine * fBasesPerLine);
  595.         if (doSequence && fDoLeftName) DrawName( atSeq, 0, atBase);
  596.         }    else if ((aCell.h == 2)) {
  597.         //indexLeft
  598.         atBase= fFirstBase + min( fNbases, seqLine * fBasesPerLine);
  599.         if (doSequence && fDoLeftIndex) DrawSideIndex( atBase, kNucBorder);
  600.         }        
  601.     else if ((aCell.h < fBasesPerLine+3)) {
  602.         //bases
  603.         atBase= (seqLine * fBasesPerLine) + aCell.h - 2;
  604.         if ((atBase <= fNBases)) {
  605.             atBase= fFirstBase - 1 + atBase;     //atbase == 0  for first 
  606.             if (doSequence) DrawNuc( atSeq, atBase)
  607.             else if (doTopIndex && fDoTopIndex) DrawTopIndex( atBase);
  608.             }
  609.         }        
  610.     else if ((aCell.h == fBasesPerLine+3)) {
  611.         //indexRight
  612.         atBase= fFirstBase - 1 + min( fNBases, (seqLine+1) * fBasesPerLine);
  613.         if (doSequence && fDoRightIndex) DrawSideIndex( atBase, 0);
  614.         }    else if ((aCell.h == fBasesPerLine+4)) {
  615.         //nameRight
  616.         atBase= fFirstBase - 1 + min( fNBases, (seqLine+1) * fBasesPerLine);
  617.         if (doSequence && fDoRightName) DrawName( atSeq, kNucBorder, atBase);
  618.         }
  619. }
  620.  
  621.  
  622.  
  623. pascal void TSeqPrintView::CalcMinFrame(VRect VAR minFrame)
  624. {
  625.     inherited::CalcMinFrame( minFrame);
  626. }
  627.  
  628.  
  629.  
  630.  
  631. pascal void TSeqPrintView::DoMenuCommand(CommandNumber aCommandNumber) // override 
  632. {
  633.     switch (aCommandNumber) {
  634.         cCopy: {
  635.                 this->WriteToDeskScrap(); 
  636.                 gClipboardMgr->CheckDeskScrap(); //! this notifies app of changed scrap 
  637.                 }
  638.         otherwise
  639.             inherited::DoMenuCommand(aCommandNumber);
  640.         }
  641. }
  642.  
  643.  
  644. /*******
  645. pascal TCommand TSeqPrintView::DoMouseCommand(Point VAR theMouse, EventInfo VAR info,
  646.                                    Point VAR hysteresis)
  647. VAR
  648.         FailInfo        fi;
  649.  
  650.     pascal void HdlInitCmdFailed(OSErr error, long message)
  651.         {
  652.         FreeIfObject(protoSeqPrint);
  653.         protoSeqPrint = NULL;
  654.         }
  655.  
  656.     {                    
  657.     DoMouseCommand = NULL;
  658.  
  659.     fClickPt = theMouse;
  660.     if (palette->fCurrSeqPrint > 0) { // draw mode
  661.         FailSpaceIsLow();                                 // Make sure we aren't low on memory 
  662.  
  663.         Deselect();
  664.  
  665.         //Clone appropriate SeqPrint
  666.  
  667.         protoSeqPrint = TSeqPrint(gSeqPrintsArray[palette->fCurrSeqPrint].Clone);
  668.         FailNil(protoSeqPrint);
  669.  
  670.         CatchFailures(fi, HdlInitCmdFailed);
  671.         // Make sure cloning the SeqPrint left us with enough memory to continue.
  672.         FailSpaceIsLow();
  673.  
  674.         New(SeqPrintSketcher);
  675.         FailNil(SeqPrintSketcher);
  676.         SeqPrintSketcher->ISeqPrintSketcher(this, protoSeqPrint, info.theOptionKey);
  677.         Success(fi);
  678.         DoMouseCommand = SeqPrintSketcher;
  679.         }            
  680.         
  681.     else {         //select mode
  682.         SeqPrintUnderMouse = NULL;
  683.         fSeqPrintDocument->EachVirtualSeqPrintDo(CheckSeqPrint);
  684.  
  685.         if (SeqPrintUnderMouse == NULL)    {        //area select
  686.             if (!info.theShiftKey)
  687.                 Deselect();
  688.             New(SeqPrintSelector);
  689.             FailNil(SeqPrintSelector);
  690.             SeqPrintSelector->ISeqPrintSelector(cMouseCommand, this);
  691.             DoMouseCommand = SeqPrintSelector;
  692.             } 
  693.  
  694.         else {                                        //SeqPrint select/move/...
  695.             if (!(SeqPrintUnderMouse->fIsSelected || info.theShiftKey))
  696.                 Deselect();
  697.  
  698.             if (info.theShiftKey) {
  699.                 SeqPrintUnderMouse->fIsSelected = !SeqPrintUnderMouse->fIsSelected;
  700.                 if (SeqPrintUnderMouse->fIsSelected)
  701.                     SeqPrintUnderMouse->Highlight(hlOff, hlOn)
  702.                 else
  703.                     SeqPrintUnderMouse->Highlight(hlOn, hlOff);
  704.                 }            else if (!SeqPrintUnderMouse->fIsSelected)
  705.                 {
  706.                 SeqPrintUnderMouse->fIsSelected = TRUE;
  707.                 DoHighlightSelection(hlOff, hlOn);
  708.                 }
  709.  
  710.             if (SeqPrintUnderMouse->fIsSelected) {
  711.                 New(SeqPrintDragger);
  712.                 FailNil(SeqPrintDragger);
  713.                 SeqPrintDragger->ISeqPrintDragger(this);
  714.                 DoMouseCommand = SeqPrintDragger;
  715.                 }
  716.             //else, fall-through, we return NULL
  717.             }     
  718.         }                     
  719. }                                        
  720. **********/
  721.  
  722.  
  723.  
  724. pascal void TSeqPrintView::DoSetupMenus(void)
  725.     {
  726.         short        i;
  727.         Boolean        anySelection;
  728.         Boolean        haveMemory;
  729.         MenuHandle        aMenuHandle;
  730.         short        item;
  731.         Str255        itemName;
  732.  
  733.  
  734.     inherited::DoSetupMenus();
  735.  
  736.     anySelection = FALSE;
  737.     haveMemory = !MemSpaceIsLow;
  738.  
  739.     Enable(cCopy, TRUE && haveMemory);
  740. /*----    
  741.     Enable(cCut, anySelection && haveMemory);
  742.     if (haveMemory) CanPaste(kPrintClipType);
  743.     Enable(cClear, anySelection);
  744. -------*/
  745. }             
  746.  
  747.